﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package reprise.css.propertyparsers {
    import reprise.css.*;
    import reprise.utils.*;
    import com.robertpenner.easing.*;

    public class Transition extends CSSPropertyParser {

        public static const EASINGS:Object = {linear:Linear.easeNone, Quad:Quad, Quint:Quint, Quart:Quart, Cubic:Cubic, Back:Back, Bounce:Bounce, Circ:Circ, Sine:Sine};
        public static const KNOWN_PROPERTIES:Object = {RepriseTransition:{parser:parseRepriseTransition}, RepriseTransitionProperty:{parser:parseRepriseTransitionProperty}, RepriseTransitionDuration:{parser:parseRepriseTransitionDuration}, RepriseTransitionDelay:{parser:parseRepriseTransitionDelay}, RepriseTransitionTimingFunction:{parser:parseRepriseTransitionTimingFunction}, RepriseTransitionDefaultValue:{parser:parseRepriseTransitionDefaultValue}, transitionFrameDropping:{parser:strToStringProperty, inheritable:true}};

        public static function parseRepriseTransitionProperty(_arg1:String, _arg2:String):CSSProperty{
            var _local3:Object = strToProperty(_arg1, _arg2);
            var _local4:CSSProperty = _local3.property;
            if (_local4.inheritsValue()){
                return (_local4);
            };
            var _local5:Array = (_local3.filteredString as String).split(",");
            var _local6:int = _local5.length;
            while (_local6--) {
                _local5[_local6] = CSSParsingHelper.camelCaseCSSValueName(_local5[_local6]);
            };
            _local4.setSpecifiedValue(_local5);
            return (_local4);
        }
        public static function parseRepriseTransitionTimingFunction(_arg1:String, _arg2:String):CSSProperty{
            var _local6:String;
            var _local3:Object = strToProperty(_arg1, _arg2);
            var _local4:CSSProperty = _local3.property;
            if (_local4.inheritsValue()){
                return (_local4);
            };
            var _local5:Array = [];
            for each (_local6 in CSSParsingHelper.splitPropertyList((_local3.filteredString as String))) {
                _local5.push(parseRepriseTransitionTimingFunctionPart(_local6, _arg2));
            };
            _local4.setSpecifiedValue(_local5);
            return (_local4);
        }
        public static function parseRepriseTransitionPart(_arg1:String, _arg2:String):Object{
            var _local3:Object = {};
            var _local4:Object = extractFunctionLiteralFromString(_arg1, "default", false);
            _local3.defaultValue = _local4.functionLiteral;
            _arg1 = _local4.filteredString;
            _local4 = extractDurationFromString(_arg1, _arg2);
            _local3.duration = _local4.duration;
            _arg1 = _local4.filteredString;
            _local4 = extractDurationFromString(_arg1, _arg2);
            _local3.delay = _local4.duration;
            _arg1 = _local4.filteredString;
            _local4 = extractPropertyNameFromString(_arg1);
            _local3.property = _local4.propertyName;
            _arg1 = _local4.filteredString;
            _local3.easing = parseRepriseTransitionTimingFunctionPart(_arg1, _arg2);
            return (_local3);
        }
        public static function parseRepriseTransition(_arg1:String, _arg2:String):CSSParsingResult{
            var _local12:String;
            var _local13:CSSProperty;
            var _local14:CSSProperty;
            var _local15:CSSProperty;
            var _local16:CSSProperty;
            var _local17:CSSProperty;
            var _local18:Object;
            var _local3:Object = CSSParsingHelper.removeImportantFlagFromString(_arg1);
            var _local4:Boolean = _local3.important;
            _arg1 = _local3.result;
            var _local5:CSSParsingResult = new CSSParsingResult();
            var _local6:Array = [];
            var _local7:Array = [];
            var _local8:Array = [];
            var _local9:Array = [];
            var _local10:Array = [];
            var _local11:Array = CSSParsingHelper.splitPropertyList(_arg1);
            for each (_local12 in _local11) {
                _local18 = parseRepriseTransitionPart(_local12, _arg2);
                if (_local18){
                    _local6.push(_local18.property);
                    _local7.push(_local18.duration);
                    _local8.push(_local18.easing);
                    _local9.push(_local18.delay);
                    _local10.push(_local18.defaultValue);
                };
            };
            _local13 = new CSSProperty();
            _local13.setImportant(_local4);
            _local13.setSpecifiedValue(_local6);
            _local5.addPropertyForKey(_local13, "RepriseTransitionProperty");
            _local14 = new CSSProperty();
            _local14.setImportant(_local4);
            _local14.setSpecifiedValue(_local7);
            _local5.addPropertyForKey(_local14, "RepriseTransitionDuration");
            _local15 = new CSSProperty();
            _local15.setImportant(_local4);
            _local15.setSpecifiedValue(_local8);
            _local5.addPropertyForKey(_local15, "RepriseTransitionTimingFunction");
            _local16 = new CSSProperty();
            _local16.setImportant(_local4);
            _local16.setSpecifiedValue(_local9);
            _local5.addPropertyForKey(_local16, "RepriseTransitionDelay");
            _local17 = new CSSProperty();
            _local17.setImportant(_local4);
            _local17.setSpecifiedValue(_local10);
            _local5.addPropertyForKey(_local17, "RepriseTransitionDefaultValue");
            return (_local5);
        }
        public static function parseRepriseTransitionDefaultValue(_arg1:String, _arg2:String):CSSProperty{
            var _local6:String;
            var _local3:Object = strToProperty(_arg1, _arg2);
            var _local4:CSSProperty = _local3.property;
            if (_local4.inheritsValue()){
                return (_local4);
            };
            var _local5:Array = [];
            for each (_local6 in (_local3.filteredString as String).split(",")) {
                _local5.push(StringUtil.trim(_local6));
            };
            _local4.setSpecifiedValue(_local5);
            return (_local4);
        }
        public static function parseRepriseTransitionDelay(_arg1:String, _arg2:String):CSSProperty{
            return (parseRepriseTransitionDuration(_arg1, _arg2));
        }
        public static function parseRepriseTransitionDuration(_arg1:String, _arg2:String):CSSProperty{
            var _local6:String;
            var _local3:Object = strToProperty(_arg1, _arg2);
            var _local4:CSSProperty = _local3.property;
            if (_local4.inheritsValue()){
                return (_local4);
            };
            var _local5:Array = [];
            for each (_local6 in (_local3.filteredString as String).split(",")) {
                _local5.push(strToDurationProperty(_local6, _arg2));
            };
            _local4.setSpecifiedValue(_local5);
            return (_local4);
        }
        public static function parseRepriseTransitionTimingFunctionPart(_arg1:String, _arg2:String):Function{
            var _local3:String = CSSParsingHelper.camelCaseCSSValueName(_arg1);
            var _local4:RegExp = /ease(InOut|In|Out)(\w+)/;
            var _local5:Array = _local4.exec(_local3);
            if (!_local5){
                return (null);
            };
            var _local6:Class = EASINGS[_local5[2]];
            if (!_local6){
                return (null);
            };
            return (_local6[("ease" + _local5[1])]);
        }

    }
}//package reprise.css.propertyparsers 
